<!DOCTYPE html>
<html lang="en">

<head>
    <title></title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="../res/css/weui.css" />
    <link rel="stylesheet" href="../res/css/weuix.css" />
    <link rel="stylesheet" href="../res//css/common.css">
    <link rel="stylesheet" href="../res/css/swiper.css">
    <link rel="stylesheet" href="../res/css/quill.snow.css">
    <script src="../res/js/zepto.min.js"></script>
    <script src="../res/js/zepto.weui.js"></script>
    <script src="../res/js/common.js?v=1"></script>
    <script src="../res/js/swiper.js"></script>
    <script src="../res/js/socket.js"></script>
</head>
<style>
    .fix-top {
        border-bottom: 1px solid #e8e8e8;
        position: fixed;
        left: 0;
        top: 0;
        right: 0;
        z-index: 1;
        background: #F6F6F9
    }

    .doctor_information {
        width: 90%;
        margin: 20px 5%;
        background-color: #fff;
        border-radius: 10px;
        position: relative;
        overflow: hidden;
    }

    #name {
        width: 100%;
        font-size: 16px;
        font-family: PingFang SC;
        font-weight: bold;
        color: #353535;
    }

    #message {
        font-size: 13px;
        font-family: PingFang SC;
        font-weight: 500;
        color: #2C2C2C;
    }

    .description {
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: 500;
        color: #353535;
        letter-spacing: 0.5px;
        margin: 20px 5%;
    }

    .desMessage {
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: 500;
        color: #353535;
        letter-spacing: 0.5px;
        margin: 10px 5%;
        height: 100px;
        position: relative;
        overflow: hidden;
    }

    .duty_plan {
        width: 40%;
        border-radius: 10px;
        margin-bottom: 100px;
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: 500;
        color: #1189FF;
        text-align: center;
    }

    .Unfold {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin: 20px 15% 20px 5%;
        position: relative;
    }

    .swiperTitle {
        font-size: 16px;
        font-family: PingFang SC;
        font-weight: 500;
        font-weight: bold;
        color: #353535;
        width: 100%;
        text-align: center;
        margin: 2px 0;
    }

    .swiperPrice {
        font-size: 16px;
        font-family: PingFang SC;
        font-weight: 500;
        color: #FA6464;
        margin: 5px 0;
        margin-bottom: 10px;
    }

    .fixed-top {
        border-bottom: 1px solid #e8e8e8;
        position: fixed;
        left: 0;
        top: 0;
        right: 0;
        z-index: 1;
        background: #F6F6F9
    }

    * {
        margin: 0;
        padding: 0;
    }

    .weui-cells {
        padding-bottom: 60px;
    }

    .weui-cell {
        padding: 0;
        margin: 0;
        margin-left: 10px;
        width: 47%;
        margin-bottom: 0;
        display: inline-block;
    }

    .weui-search-bar {
        display: inline-block;
        padding: 0;
        width: 47%;
    }

    .weui-search-bar__cancel-btn {
        top: 56px;
    }

    .weui-search-bar__label {
        top: 0px;
        right: 0px;
        bottom: 0px;
        left: 0px;
        border-radius: 5px;
    }

    .weui-select {
        z-index: 0;
        height: 30px;
        line-height: 30px;
    }

    .weui-search-bar__box .weui-search-bar__input {
        width: 80%;
    }

    .weui-search-bar__box .weui-icon-clear {
        right: 24px;
    }

    .weui-tabbar__item {
        padding: 5px 0px 10px 0px;
    }

    .expertlist_map {
        margin: 0;
        margin-bottom: 10px;
    }

    .weui-dialog {
        border-radius: 12px;
    }

    .feeInfoDate span {
        color: #1189FF;
    }

    #start {
        background-color: #ECF6FF;
        height: 40px;
        line-height: 30px;
        margin-top: 10px;
        border-radius: 10px;
    }

    #start span {
        background-color: #1189ff;
        color: #ffffff;
        margin: 0 5px;
        margin-top: 5px;
        width: 30px;
        height: 30px;
        display: inline-block;
        border-radius: 5px;
    }

    #androidDialog1 .weui-mask {
        z-index: 2000;
    }

    .weui-tabbar__item {
        padding: 5px 0px 10px 0px;
    }

    .swiper-slide {
        width: 22%;
        color: #000;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        box-shadow: 0px 16px 36px 0px rgba(221, 219, 219, 0.4);
        border-radius: 10px;
        box-sizing: content-box;

    }

    .iconImage {
        width: 60px;
        height: auto;
        margin-top: 10px;
        margin-bottom: 0 !important;
    }

    .select {
        border: 2px solid #1189FF;
        box-sizing: border-box;
    }

    .select image {
        margin: 6px 0;
    }

    /* 弹出框样式 */
    .popubBox {
        width: 80%;
        background-color: #fff;
        position: fixed;
        top: 15%;
        bottom: 15%;
        left: 10%;
        z-index: 100;
        border-radius: 10px;
        display: flex;
        flex-direction: column;
    }

    .title {
        height: 40px;
        line-height: 40px;
        text-align: center;
        font-family: PingFang SC;
        font-weight: bold;
        color: #353535;
        font-size: 20px;
        padding: 10px;
    }

    .titleMessage {
        width: 90%;
        flex-grow: 1;
        margin: 5px 5%;
        font-size: 16px;
        font-family: PingFang SC;
        font-weight: 500;
        color: #333333;
        overflow: auto;
    }

    .btnList {
        width: 90%;
        margin: 15px 5%;
        display: flex;
        flex-shrink: 0;
    }

    .btn1 {
        /* width: 45%; */
        flex-grow: 1;
        margin: 0 2.5%;
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: 500;
        color: #1189FF;
        background-color: #fff;
        text-align: center;
        line-height: 40px;
        height: 40px;
        border: 2px solid #03A6FF;
        border-radius: 20px;
    }

    .btn2 {
        /* width: 45%; */
        flex-grow: 1;
        margin: 0 2.5%;
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: 500;
        color: #fff;
        background-color: #1189FF;
        border-radius: 10px;
        text-align: center;
        line-height: 40px;
        height: 40px;
        border: 2px solid #1189FF;
        border-radius: 20px;
    }

    .popubBoxs {
        width: 70%;
        ;
        background-color: #fff;
        position: fixed;
        top: 250px;
        left: 15%;
        z-index: 100;
        border-radius: 10px;
    }

    .titleMessages {
        width: 85%;
        margin: 5px 5%;
        font-size: 16px;
        font-family: PingFang SC;
        font-weight: 500;
        color: #333333;
        padding: 30px 2.5%;
    }

    .btnLists {
        width: 100%;
        display: flex;
        border-top: 1px #E0E0E0 solid;
    }

    .btn1s {
        width: 45%;
        margin: 0 2.5%;
        font-size: 15px;
        font-family: PingFang SC;
        font-weight: bold;
        color: #000;
        background-color: #fff;
        text-align: center;
        line-height: 50px;
        height: 50px;
    }

    .btn2s {
        width: 45%;
        margin: 0 2.5%;
        font-size: 15px;
        font-family: PingFang SC;
        font-weight: bold;
        color: #1189FF;
        border-radius: 10px;
        text-align: center;
        line-height: 50px;
        height: 50px;
    }

    /* 医生分享卡片样式 */
    .doctor_card {
        width: 80%;
        height: 510px;
        background-color: #fff;
        position: fixed;
        display: flex;
        justify-content: center;
        align-items: center;
        flex-wrap: wrap;
        top: 86px;
        left: 10%;
        z-index: 100;
        overflow: hidden;
    }

    .qrCode {
        width: 100%;
        z-index: 99;
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: 500;
        color: #FFFFFF;
        text-align: center;
    }

    .bottomMessage {
        width: 100%;
        z-index: 99;
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: 500;
        color: #FFFFFF;
        text-align: center;
        width: 90%;
        display: flex;
        margin: 0 5%;
        margin-bottom: 20px;
    }

    .doctorImage {
        width: 80px;
        height: 80px;
        border-radius: 50%;
        margin-top: 20px;
    }

    .doctorName {
        font-size: 16px;
        font-family: PingFang SC;
        font-weight: bold;
        color: #2C2C2C;
        margin: 0 3%;
    }

    .doctorGoodAt {
        width: 100%;
        display: flex;
        justify-content: center;
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: 500;
        color: #2C2C2C;
    }

    .backgroundBlue {
        width: 100%;
        height: 139px;
        background: #1189FF;
        position: absolute;
        bottom: 0;
        border-radius: 10px;
    }

    /* 立即咨询按钮 */
    #consult_now {
        width: 50%;
        text-align: center;
        background: #1189FF;
        color: #FEFEFE;
        border-radius: 10px;
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: bold;
        padding: 10px 10px;
    }

    /* 解释说明 */
    .Explanation {
        width: 90%;
        margin: 10px 5%;
        border-radius: 10px;
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: 500;
        padding: 10px 0
    }

    /* 分享按钮 */
    #share {
        background: rgba(17, 137, 255, 0.06);
        box-shadow: 0px 4px 11px 0px rgba(17, 137, 255, 0.2);
        border-radius: 5px;
        display: flex;
        height: 22px;
        padding: 0 5px;
        width: 25%;
    }

    /* 取消关注弹窗 */
    .cConcern {
        width: 100%;
        position: fixed;
        bottom: 0px;
        border-top: 1px solid #e8e8e8;
        background-color: #fff;
        font-family: PingFang SC;
        font-weight: 500;
        transition: all 0.2s;
        bottom: -150px;
    }

    .noChoosePay {
        background: #F4F4F4;
    }

    .noChoosePay p {
        color: #757575;
    }

    /* 医生所有服务未开启中间样式 */
    .noServer {
        height: 150px;
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
    }

    .noServer>img {
        width: 60%;
        height: 100px;
    }

    .noServer>p {
        width: 100%;
        font-size: 15px;
        font-family: PingFang SC;
        font-weight: 500;
        color: #2C2C2C;
        text-align: center;
    }

    .darkP {
        position: absolute;
        bottom: 100px;
        left: 20%;
        font-size: 16px;
        font-family: PingFang SC;
        font-weight: bold;
        color: #FFFFFF;
        display: none;
    }

    .swiper-wrapper{
        justify-content: space-evenly;
    }
</style>
<script>
    $(function () {
        if (top.location != self.location) top.location = self.location;

        // console.log(.replace(/^\?/, "11"));
        console.log();
        var doctor_id = getQst("doctor_id"); //获取Url中的医生ID
        // console.log(doctor_id);
        userJson = getUserInfo()
        h5token = userJson.h5Token //获取用户信息相关
        userid = userJson.id;
        usertype = userJson.type;
        doctor_name = "" //医生名字
        isOnline = 0 //在线状态 0为离线，1为在线
        isConcern = false //是否关注医生
        haveFee = 0, haveFeeDoctorName = '', haveFeeLogType = 0, logId = 0 //判断是否有记录变量
        index = 0, //轮播图变量
            inquiryType = "", //问诊方式
            feePay = "", //支付金额
            feeData = "", //查到的订单信息
            doctorInquiryType = 0, //医生选择的问诊类型
            doctorPackageInfoResps = [], //医生详情中的费用及套餐状态
            pauseServerIcon = ["../res/images/img_doctor_invalid@2x.png",
                "../res/images/img_consulting_invalid@2x.png", "../res/images/img_video_invalid@2x.png",
                "../res/images/img_image_invalid@2x.png"
            ], //医生没选服务的Icon图片
            ServerChoose = true //医生是否开启了服务,为false则关闭了所有服务

        QRImage = '' //医生二维码

        //建立webscoket连接//初始化webscoket
        // function initWebSocket() {
        //     // 连接socket 重构的聊天要用到socket
        //     var token = null;
        //     var userJson = localStorage.getItem('DSXBuserJson');
        //     user_id = strToJson(userJson).id
        //     if (userJson) {
        //         token = strToJson(userJson).h5Token
        //     }
        //     wsConnection.initWebSocket('wss://hospital-test.yixianmedical.com/websocket', token);
        // }
        // initWebSocket()

        //请求获取付费信息
        function newGetConsultationFee(fn) {
            var params = {
                "doctorId": doctor_id,
            }
            newAjaxPost("/h5/wxpay/getConsultationFee", params, fn);
        }

        //获取是否有付费信息
        newGetConsultationFee((jsonInfo) => {
            feeData = jsonInfo.data
        })

        function refee() {
            var params = {
                "doctorId": doctor_id,
                "isFrozen": 0
            }
            newAjaxPost("/h5/wxpay/refund", params, (json) => {
                msgInfo(json.msg);
                if (inquiryType == 1 || inquiryType == 2) {
                    $('.popubBoxs').hide();
                    $(".darkBackgroud").hide();
                    setTimeout(() => {
                        location.reload()
                    })
                } else {
                    let param = {
                        id: feeData.logId
                    }
                    newAjaxPost("/h5/dectorEndInquiry/unSuccessfulInquiry", param, (res) => {
                        if (res.code == 1) {
                            $('.popubBoxs').hide();
                            $(".darkBackgroud").hide();
                            setTimeout(() => {
                                location.reload()
                            })
                        } else {
                            $('.popubBoxs').hide();
                            $(".darkBackgroud").hide();
                            setTimeout(() => {
                                location.reload()
                            })
                        }
                    })
                }
            });
        }

        //退款
        $(".btn1s").click( refee )

        //轮播图变化函数
        function navbar() {
            var data = feeData;
            //data为空就没有订单
            if (data) {
                //有图文问诊和视频问诊记录
                doctor_imid = data.doctorIm
                patientIM = data.userIm
                //haveFeeLogType 1视频 2.图文 3.家庭 4.复诊
                haveFeeLogType = data.inquiryType;
                logId = data.logId
                //详情页面显示,价格改变
                $(".Explanation").hide()
                $(".Explanation").eq(index).show()
                inquiryType = $(".swiper-slide").eq(index).attr("num")
                //边框显示
                $(".swiper-slide").eq(index).addClass("select")
                $(".swiper-slide").eq(index).siblings().removeClass("select")
                //图标显示
                $(".selectI").hide()
                $(".selectI").eq(index).show()
                //图片下移
                $(".iconImage").css("margin", "10px 0")
                $(".iconImage").eq(index).css("margin-top", "6px")
                feePay = $(".swiper-slide").eq(index).attr("pay") * 100
                $(".askPrice").text('￥' + ($(".swiper-slide").eq(index).attr("pay")))
                //判断是否是现在这个医生的记录
                if (data.doctorId == doctor_id) {
                    switch (Number(haveFeeLogType)) {
                        case 1:
                            $("#consult_now").removeClass()
                            if (index == 2) {
                                $("#consult_now").text(`立即咨询`)
                                $("#consult_now").addClass(`hasPayFee`)
                            } else {
                                $("#consult_now").text(
                                    `${$(".swiperTitle").eq(index).text()} ￥ ${$(".swiper-slide").eq(index).attr("pay")}`
                                )
                                $("#consult_now").addClass("noPayFee")
                            }
                            break;
                        case 2:
                            $("#consult_now").removeClass()
                            if (index == 3) {
                                $("#consult_now").text(`立即咨询`)
                                $("#consult_now").addClass(`hasPayFee`)
                            } else {
                                $("#consult_now").text(
                                    `${$(".swiperTitle").eq(index).text()} ￥ ${$(".swiper-slide").eq(index).attr("pay")}`
                                )
                                $("#consult_now").addClass("noPayFee")
                            }
                            break;
                        case 3:
                            $("#consult_now").removeClass()
                            if (index == 0) {
                                $("#consult_now").text(`立即咨询`)
                                $("#consult_now").addClass(`hasPayFee`)
                                $("#consult_now").attr("logId", data.logId)
                            } else {
                                $("#consult_now").text(
                                    `${$(".swiperTitle").eq(index).text()} ￥ ${$(".swiper-slide").eq(index).attr("pay")}`
                                )
                                $("#consult_now").addClass("noPayFee")
                            }
                            break;
                        case 4:
                            $("#consult_now").removeClass()
                            if (index == 1) {
                                $("#consult_now").text(`立即咨询`)
                                $("#consult_now").addClass(`hasPayFee`)
                                $("#consult_now").attr("logId", data.logId)
                            } else {
                                $("#consult_now").text(
                                    `${$(".swiperTitle").eq(index).text()} ￥ ${$(".swiper-slide").eq(index).attr("pay")}`
                                )
                                $("#consult_now").addClass("noPayFee")
                            }
                            break;
                    }
                } else {
                    $("#consult_now").text(
                        `${$(".swiperTitle").eq(index).text()} ￥ ${$(".swiper-slide").eq(index).attr("pay")}`
                    )
                    switch (Number(haveFeeLogType)) {
                        case 1:
                            $("#consult_now").removeClass()
                            if (index == 2) {
                                $("#consult_now").addClass(`hasPayFee`)
                            } else {
                                $("#consult_now").addClass("noPayFee")
                            }
                            break;
                        case 2:
                            $("#consult_now").removeClass()
                            if (index == 3) {
                                $("#consult_now").addClass(`hasPayFee`)
                            } else {
                                $("#consult_now").addClass("noPayFee")
                            }
                            break;
                        case 3:
                            $("#consult_now").removeClass()
                            if (index == 0) {
                                $("#consult_now").addClass(`hasPayFee`)
                                $("#consult_now").attr("logId", data.logId)
                            } else {
                                $("#consult_now").addClass("noPayFee")
                            }
                            break;
                        case 4:
                            $("#consult_now").removeClass()
                            if (index == 1) {
                                $("#consult_now").addClass(`hasPayFee`)
                                $("#consult_now").attr("logId", data.logId)
                            } else {
                                $("#consult_now").addClass("noPayFee")
                            }
                            break;
                    }
                }
            }
            //没有记录 
            else {
                //详情页面显示,价格改变
                $(".Explanation").hide()
                $(".Explanation").eq(index).show()
                inquiryType = $(".swiper-slide").eq(index).attr("num")
                //边框显示
                $(".swiper-slide").eq(index).addClass("select")
                $(".swiper-slide").eq(index).siblings().removeClass("select")
                //图标显示
                $(".selectI").hide()
                $(".selectI").eq(index).show()
                //图片下移
                $(".iconImage").css("margin", "10px 0")
                $(".iconImage").eq(index).css("margin-top", "6px")
                feePay = $(".swiper-slide").eq(index).attr("pay") * 100
                $(".askPrice").text('￥' + ($(".swiper-slide").eq(index).attr("pay")))
                $("#consult_now").text(
                    `${$(".swiperTitle").eq(index).text()} ￥ ${$(".swiper-slide").eq(index).attr("pay")}`
                )
                // feePay = $(".swiper-slide").eq(3).attr("pay") * 100
                // $(".askPrice").text('￥' + ($(".swiper-slide").eq(3).attr("pay")))
            }
        }

        //	轮播图
        function swpier() {
            var mySwiper = new Swiper('.swiper-container', {
                loop: false,
                autoplay: false,
                pagination: {
                    el: '.swiper-pagination',
                },
                slidesPerView: 'auto',
                on: {
                    click: function () {
                        index = this.clickedIndex
                        // console.log(index);
                        let isChoosePay = this.slides[index].className.indexOf("noChoosePay") != -1
                        if (isChoosePay) {} else {
                            navbar()
                        }
                    },
                },
            })
        }

        //请求获得医生具体信息渲染页面
        function showDoctor() {
            var paramJson = {
                "id": parseInt(doctor_id),
                "im": userid
            };
            newAjaxPost("/h5/doctorInfo/getDoctorInfo", paramJson, showDoctorOk);
        }


        function showDoctorOk(json) {
            // console.log(json);
            doctorPackageInfoResps = serverSort(json.data.doctorPackageInfoResps)
            // console.log(doctorPackageInfoResps);
            var message = "";
            data = json.data
            doctor_name = data.trueName
            isOnline = data.isOnline;
            isConcern = data.isConcern
            doctorInquiryType = data.inquiryType
            message = `    <div class="doctor_information" style="margin-top:60px">
        <div style="margin:20px 5%;display: flex;">
            <div class="expertlist_map_img" style="margin-right:5%"> <img src=${data.doctorHeadImg} /> </div>
            <div style="display:flex;flex-wrap:wrap;">
                <p id="name">${data.trueName}</p>
                <p id="message">${data.doctorJobTitle}&nbsp|&nbsp${data.departmentName}&nbsp|&nbsp从业${data.workAge}年</p>
            </div>
            <div id="share">
                <img src="../res/images/icon_share.png" style="width: 30%;height: 22px;" />
                <p style="font-size: 13px;font-family: PingFang SC;font-weight: bold;color: #1189FF;width:70%;text-align: center;">分享</p>
            </div>
        </div>
        <div class="description Unfold">
            ${data.doctorSpecialty}
        </div>
        `
            if (data.doctorSpecialty) {
                message +=
                    `<div style="font-size: 14px;font-family: PingFang SC;font-weight: bold;color: #1189FF;position: absolute;right: 7%;bottom:20px" class="conceal">收起</div>
            <div style="font-size: 14px;font-family: PingFang SC;font-weight: bold;color: #1189FF;position: absolute;right: 7%;bottom:20px;"class="open_up">展开</div>`
            } else {

            }
            message += `    
    </div>
    <div style="background-color: #fff;overflow: hidden;">
        <div style="width: 90%;margin: 20px 5%;display: flex; justify-content: space-between">
            <p style="font-size: 20px;font-family: PingFang SC;font-weight: bold;color: #2C2C2C;">
                医生服务</p>
            <p style="font-size: 15px;font-family: PingFang SC;font-weight: 500;color: #1189FF;line-height: 32px;" id="isConcern">
                添加家庭医生</p>
            <p style="font-size: 15px;font-family: PingFang SC;font-weight: 500;color: #999999;line-height: 32px;" id="cancalConcern">
                添加家庭医生</p>
        </div>
        <div class="swiper-container" >
            <div class="swiper-wrapper" style="margin-bottom:6px">
                    <div class="swiper-slide select" num="3" id=${doctor_id} docname=${data.trueName} pay=${doctorPackageInfoResps[0].price/100} packageType=${doctorPackageInfoResps[0].packageType} enable=${doctorPackageInfoResps[0].enable}>
                        <img src="../res/images/img_doctor@2x.png" alt="" class="iconImage">
                        <p class="swiperTitle">家庭医生</p>
                        <p class="swiperPrice">￥${doctorPackageInfoResps[0].price/100}/次</p>
                        <img src="../res/images/icon_select.png" alt="" style="width: 32px;position: absolute;height:20px;top:-2px;right:-2px" class="selectI">
                    </div>
                    <div class="swiper-slide" style="color: #1A99D5;" num="4" id=${doctor_id} docname=${data.trueName} pay=${doctorPackageInfoResps[1].price/100} packageType=${doctorPackageInfoResps[1].packageType} enable=${doctorPackageInfoResps[1].enable}>
                        <img src="../res/images/img_consulting@2x.png" alt="" class="iconImage">
                        <p class="swiperTitle">复诊</p>
                        <p class="swiperPrice">
                            ￥${doctorPackageInfoResps[1].price/100}/次</p>
                            <img src="../res/images/icon_select.png" alt="" style="width: 32px;position: absolute;height:20px;top:-2px;right:-2px" class="selectI">
                    </div>
                    <div class="swiper-slide" style="color: #19A969;" num="1" id=${doctor_id} docname=${data.trueName} pay=${doctorPackageInfoResps[2].price/100} packageType=${doctorPackageInfoResps[2].packageType} enable=${doctorPackageInfoResps[2].enable}>
                        <img src="../res/images/img_video@2x.png" alt="" class="iconImage">
                        <p class="swiperTitle">视频问诊</p>
                        <p class="swiperPrice">
                            ￥${doctorPackageInfoResps[2].price/100}/次</p>
                            <img src="../res/images/icon_select.png" alt="" style="width: 32px;position: absolute;height:20px;top:-2px;right:-2px" class="selectI">
                    </div>
                    <div class="swiper-slide" style="color: #8472B5;" num="2" id=${doctor_id} docname=${data.trueName} pay=${doctorPackageInfoResps[3].price/100} packageType=${doctorPackageInfoResps[3].packageType} enable=${doctorPackageInfoResps[3].enable}>
                        <img src="../res/images/img_image@2x.png" alt="" class="iconImage">
                        <p class="swiperTitle">图文问诊</p>
                        <p class="swiperPrice">
                            ￥${doctorPackageInfoResps[3].price/100}/次</p>
                            <img src="../res/images/icon_select.png" alt="" style="width: 32px;position: absolute;height:20px;top:-2px;right:-2px" class="selectI">
                    </div>
            </div>
        </div>
        <div class="noServer">
            <img src="../res/images/img_empty_states@2x.png">
            <p>医生暂无开通服务</p>
        </div>
        <div class="Explanation">
            <p style="margin: 5px 3%;">家庭医生解释说明</p>
            <p style="margin: 5px 3%;">1:为您提供全面的、连续的、有效的、及时的和个性化医疗保健服务和照顾，更合适慢病患者</p>
            <p style="margin: 5px 3%;">2:通过图文、文字咨询医生</p>
            <p style="margin: 5px 3%;">3:咨询期间未回复，50小时后自动退款 </p>
            <p style="margin: 5px 3%;">4:医生根据情况提供建议、用药指导等，若重大疾病或紧急情况请及时前往医院就诊</p>
        </div>
        <div class="Explanation">
            <p style="margin: 5px 3%;">复诊解释说明</p>
            <p style="margin: 5px 3%;">1:顺利复诊、不折腾，更适合出院患者，非初诊患者及慢病患者</p>
            <p style="margin: 5px 3%;">2:通过图文、文字咨询医生</p>
            <p style="margin: 5px 3%;">3:咨询期间未回复，50小时后自动退款</p>
            <p style="margin: 5px 3%;">4:医生根据情况提供建议、用药指导等，若重大疾病或紧急情况请及时前往医院就诊</p>
        </div>
        <div class="Explanation">
            <p style="margin: 5px 3%;">视频问诊解释说明</p>
            <p style="margin: 5px 3%;">1:医生立刻回复，耗时短，效率高，适合一般患者</p>
            <p style="margin: 5px 3%;">2:通过图文、文字在线咨询医生</p>
            <p style="margin: 5px 3%;">3:当天有效，若没有成功问诊，24小时后自动退款或主动在首页发起退款 </p>
            <p style="margin: 5px 3%;">4:医生根据情况提供建议、用药指导等，若重大疾病或紧急情况请及时前往医院就诊</p>
        </div>
        <div class="Explanation">
            <p style="margin: 5px 3%;">图文问诊解释说明</p>
            <p style="margin: 5px 3%;">1:与医生面对面交流，沟通更方便，适合一般患者尤其是年长患者</p>
            <p style="margin: 5px 3%;">2:通过视频、文字在线咨询医生</p>
            <p style="margin: 5px 3%;">3:当天有效，若没有成功问诊，24小时后自动退款或主动在首页发起退款。</p>
            <p style="margin: 5px 3%;">4:医生根据情况提供建议、用药指导等，若重大疾病或紧急情况请及时前往医院就诊</p>
        </div>
        <div style="width: 90%;margin: 20px 5%;position: relative;">
            <p style="font-size: 20px;font-family: PingFang SC;font-weight: bold;color: #2C2C2C">简介</p>
            <div class="description Unfold" style="word-break:break-all">
                ${data.doctorSynopsis}
        </div>
        `
            if (data.doctorSynopsis) {
                message +=
                    `<div style="font-size: 14px;font-family: PingFang SC;font-weight: bold;color: #1189FF;position: absolute;right: 7%;bottom:20px" class="conceal">收起</div>
                    <div style="font-size: 14px;font-family: PingFang SC;font-weight: bold;color: #1189FF;position: absolute;right: 7%;bottom:20px;"class="open_up">展开</div>`
            } else {

            }
            message += `  
        <div class="duty_plan" id="schedulingBtn" >查看医生值班计划></div>
        <div class="consultWrappar"
            style="display: flex;width: 90%;padding: 15px 5%;border-top:1px solid #e6e6e6;position: fixed;left:0%;bottom: 0;background-color: #fff;">
            <div style="font-size: 20px;font-family: PingFang SC;font-weight: bold;color: #FA6464;width: 75%;" class="askPrice">￥8/次
            </div>
            <div id="consult_now" doctorId=${doctor_id}>立即咨询</div>
            </div>
        </div>`
            $(".doctorMessage").html(message)

            //判断医生是否在线以及医生选择选择问诊置灰选项
            let swiperList = document.querySelectorAll(".swiper-slide")
            if (isOnline == 0) {
                swiperList.forEach((item, index) => {
                    let $item = $(item)
                    thatEnable = $item.attr("enable")
                    if(thatEnable == '0'){
                        $item.addClass("noChoosePay");
                        $item.children()[0].src = pauseServerIcon[index]
                    }
                })

                swiperList[2].classList.add("noChoosePay");
                swiperList[2].children[0].src = "../res/images/img_video_invalid@2x.png"
                
                swiperList[3].classList.add("noChoosePay")
                swiperList[3].children[0].src = "../res/images/img_image_invalid@2x.png"

            } else {
                doctorPackageInfoResps.forEach((ele, index) => {
                    enable = $(".swiper-slide")[index].getAttribute("enable")
                    if (enable == 0) {
                        swiperList[index].classList.add("noChoosePay")
                        swiperList[index].children[0].src = pauseServerIcon[index];
                    }
                })
                //判断医生问诊状态
                if (doctorInquiryType == 1) {
                    swiperList[3].classList.add("noChoosePay")
                    swiperList[3].children[0].src = "../res/images/img_image_invalid@2x.png"
                } else if (doctorInquiryType == 2) {
                    swiperList[2].classList.add("noChoosePay")
                    swiperList[2].children[0].src = "../res/images/img_video_invalid@2x.png"
                }
            }

            //判断医生是否关闭了所有服务
            ServerChoose = Boolean(doctorPackageInfoResps.find(item => item.enable == '1'))
            let firstElement = doctorPackageInfoResps.find((ele, index) => {
                return ele.enable == 1
            })
            // console.log(doctorPackageInfoResps, firstElement);
            if (firstElement != undefined) {
                switch (firstElement.packageType) {
                    case 1:
                        index = 2
                        break;
                    case 2:
                        index = 3
                        break;
                    case 3:
                        index = 0
                        break;
                    case 4:
                        index = 1
                        break;
                }
            }
            if(isOnline == '0' && index > 1) index = 0
            // console.log(ServerChoose);
            if (!isOnline && doctorPackageInfoResps[0].enable == 0 && doctorPackageInfoResps[1].enable == 0){
                ServerChoose = false
            }
            if (ServerChoose) {
                $(".noServer").hide()
            } else {
                $(".consultWrappar").hide()
                $(".swiper-wrapper").hide()
                $("#consult_now").hide()
            }

            //判断关注状态
            if (isConcern == null || isConcern == 0) {
                $("#cancalConcern").hide()
            } else {
                $("#isConcern").hide()
                $("#cancalConcern").show()
            }

            $("#isConcern").click(function () {
                var params = {
                    "doctorId": doctor_id,
                    "isConcern": 1
                }
                newAjaxPost("/h5/myDoctor/concernDoctor", params, concernDoctorOk);
                isConcern = 1
            })

            $("#cancalConcern").click(function () {
                $(".cConcern").css("bottom", "0px")
                $(".darkBackgroud").show()
                //请求获取付费信息,判断是否还在家庭问诊中
            })

            //点击取消关注
            $(".cancalConcern").click(function () {
                newGetConsultationFee((jsonInfo) => {
                    data = jsonInfo.data
                    if (data && data.inquiryType == 3) {
                        msgInfo("当次问诊仍未结束，请结束后再尝试")
                    } else {
                        var params = {
                            "doctorId": doctor_id,
                            "isConcern": 0
                        }
                        newAjaxPost("/h5/myDoctor/concernDoctor", params, concernDoctorOk);
                        isConcern = 0
                    }
                })
                $(this).parent().css("bottom", "-150px")
                $(".darkBackgroud").hide()
            })

            //点击关闭弹窗
            $(".cancalConcern").siblings().click(function () {
                $(this).parent().css("bottom", "-150px")
                $(".darkBackgroud").hide()
            })

            function concernDoctorOk(jsonInfo) {
                console.log(jsonInfo);
                msgInfo(jsonInfo.msg);
                if (isConcern == 1) {
                    $("#cancalConcern").hide()
                    $("#isConcern").show()
                } else {
                    $("#cancalConcern").show()
                    $("#isConcern").hide()
                }
            }
        }

        // 测试退家庭医生诊费
        // var params = {
        //     "doctorId": doctor_id,
        //     "isFrozen": 1
        // }
        // newAjaxPost("/h5/wxpay/refund", params, (jsonInfo)=>{console.log(jsonInfo);});

        showDoctor()
        navbar()

        //页面隐藏展示
        $(".popubBox").hide()
        $(".popubBoxs").hide()
        $(".darkBackgroud").hide()
        $(".doctor_card").hide()
        $(".conceal").hide()

        //服务排序
        function serverSort(arr) {
            arr1 = arr.slice(2)
            // arr2 = arr.slice(0, 2).reverse()
            arr2 = arr.slice(0, 2)
            arr2.forEach(item => {
                arr1.push(item)
            })
            return arr1
        }

        //点击返回
        $("#btnBack").click(() => {
            var isMydoctorPage = getQst("isMydoctorPage")
            if (isMydoctorPage) {
                goPage(`my_doctor_index.htm?isMydoctorPage=${isMydoctorPage}`)
            } else {
                goPage("inquiry_doctor_index.htm")
            }
        })

        //患者加入聊天室通知对方
        function noticeDoctor(patientIM, doctor_imid, logId) {
            wsConnection.send(38, {
                userIm: patientIM, //发送方im
                friendIm: doctor_imid, //接收方im
                logId: logId
            });
        }

        $(".open_up").click(function () {
            $(this).hide()
            $(this).siblings(".description").removeClass("Unfold");
            $(this).siblings(".conceal").show()
        })

        //展开收起效果
        $(".conceal").click(function () {
            $(this).hide()
            $(this).siblings(".description").addClass("Unfold");
            $(this).siblings(".open_up").show()
        })

        //查看医生值班计划
        $("#schedulingBtn").click(function () {
            if (!isLogin()) { //判断是否登录
                $.confirm("请先登录再操作", function () {
                    goPage('login.htm');
                }, function () {
                    //取消操作
                });
            } else {
                goPage('inquiry_doctor_sche.htm?doctor_id=' + doctor_id + "&rand=" + Math.random());
            }
        });

        //点击取消弹框
        $(".btn1").click(function () {
            $(".popubBox").hide()
            $(".darkBackgroud").hide()
        })

        //点击分享展示页面
        $("#share").click(function () {
            var params = {
                "doctorId": doctor_id,
                "path": `pages/user_side/index/index_doctorlist/index_doctor_details/index_doctor_details?doctorId=${doctor_id}&isShare=1`,
                "width": 430
            }
            newAjaxPost("/h5/doctoronlineconsulta/getQRCode", params, getQRCodeOk)

            function getQRCodeOk(jsonInfo) {
                console.log(jsonInfo.data.data);
                QRImage = jsonInfo.data.data;
                $.showLoading();
                createDoctorCard();
            };

        });

        let canvas = $('#doctorCardCanvas')[0];
        let canvasWidth = canvas.width;
        let canvasHeight = canvas.height;

        //绘制医生分享卡片
        function createDoctorCard() {
            var dpr = (scale = window.devicePixelRatio || 1);
            canvas.width = canvasWidth * dpr;
            canvas.height = canvasHeight * dpr;
            let ctx = canvas.getContext('2d');
            ctx.scale(dpr, dpr)


            canvas.mozImageSmoothingEnabled = false;
            canvas.webkitImageSmoothingEnabled = false;
            canvas.msImageSmoothingEnabled = false;
            canvas.imageSmoothingEnabled = false;

            ctx.fillStyle = '#fff'
            ctx.fillRect(0, 0, 300, 500)

            //相关文章画入
            ctx.fillStyle = '#000'; // 文字填充颜色
            ctx.font = 'bold 14px serif';
            ctx.fillText(data.trueName, 80, 110);
            ctx.fillStyle = '#FF9211';
            ctx.fillText('已通过认证', 150, 110);
            ctx.font = '14px serif';
            ctx.fillStyle = '#353535';
            ctx.fillText(data.doctorJobTitle, 85, 140);
            ctx.fillText('|', 145, 140);
            ctx.fillText(data.departmentName, 160, 140);
            ctx.font = ' 14px serif';
            drawtext(ctx, '擅长:' + data.doctorSpecialty, 35, 178, 245)


            //封装画图函数
            function addImage(src) {
                return new Promise((resolve, reject) => {
                    const img = new Image();
                    img.setAttribute("crossOrigin", 'Anonymous');
                    img.src = src;
                    img.onload = () => {
                        resolve(img);
                    };
                    img.onerror = () => {
                        reject();
                    };
                    if (img.complete) {
                        resolve(img);
                    }
                });
            }
            //绘制图片
            addImage("../res/images/icon_authentication.png" + '?v=' + Math.random()).then((img) => {
                //认证图片icon画入
                ctx.drawImage(img, 135, 97, 12.5, 12.5);
                //擅长图片icon画入
                addImage("../res/images/icon_be_good_at.png" + '?v=' + Math.random()).then((img) => {
                    ctx.drawImage(img, 15, 165, 12.5, 12.5);
                    // 蓝色背景图片插入
                    addImage("../res/images/img_bg@2x.png" + '?v=' + Math.random()).then((
                        img) => {
                        ctx.drawImage(img, 0, 350, 300, 150);
                        addImage(QRImage + '?v=' + Math.random()).then((img) => {
                            ctx.drawImage(img, 100, 288, 100, 100)
                            ctx.fillStyle = '#fff';
                            ctx.fillText(`hi，我是${data.trueName}医生`,
                                80, 410);
                            ctx.fillText('您可以扫二维码发起咨询。我会在最短时间', 10,
                                440);
                            ctx.fillText('内回复并给出专业的诊疗方案', 50, 470);
                            //医生头像画入
                            addImage(data.doctorHeadImg + '?v=' + Math.random())
                                .then((img) => {
                                    ctx.beginPath();
                                    // //画裁剪区域，此处以圆为例
                                    ctx.arc(148, 55, 31, 0, 2 * Math.PI);
                                    // ctx.arc(50,50,25,0,2*Math.PI);
                                    ctx.clip()
                                    ctx.drawImage(img, 115.5, 24, 65, 65)
                                    console.log(ctx);
                                    //将canvas画布转化为图片
                                    var image = new Image();
                                    image.setAttribute("crossOrigin",
                                        'Anonymous')
                                    image.src = canvas.toDataURL(
                                        "image/png", 1.5);
                                    // return image
                                    //获取医生头像图片并画入canvas
                                    $(".doctor_card").html(image)
                                    $(".doctor_card").show()
                                    $.hideLoading();
                                    $(".darkBackgroud").show()
                                    $('.darkP').show()
                                })
                        })
                    })
                });
            });

        }

        //换行文字
        //绘制换行文字
        function drawtext(ctx, t, x, y, w) {
            const chr = t.split('');
            let temp = '';
            const row = [];
            for (let a = 0; a < chr.length; a++) {
                if (
                    ctx.measureText(temp).width < w &&
                    ctx.measureText(temp + chr[a]).width <= w
                ) {
                    temp += chr[a];
                } else {
                    row.push(temp);
                    temp = chr[a];
                }
            }
            row.push(temp);
            for (let b = 0; b < row.length; b++) {
                ctx.fillStyle = '#353535';
                ctx.fillText(row[b], x, y + b * 20); //每行字体y坐标间隔14
                maxY = y + b * 20
            }
        }


        //遮罩点击关闭
        $(".darkBackgroud").click(function () {
            $(".doctor_card").hide();
            $(".darkBackgroud").hide();
            $(".cConcern").css("bottom", "-150px");
            $('.popubBox').hide();
            $('.popubBoxs').hide();
            $('.darkP').hide();
        });

        //点击隐藏弹框
        $(".btn2s").click(function () {
            $('.popubBoxs').hide();
            $(".darkBackgroud").hide();
        });

        //点击咨询
        $("#consult_now").click(function () {
            noPayFee = $(this).hasClass("noPayFee")
            hasPayFee = $(this).hasClass("hasPayFee")
            //判断医生是否开启了服务    ServerChoose为true则开启了服务，false关闭了所有服务
            if (ServerChoose) {
                //通过类目判断是否是买了的那个服务
                //不是该服务
                if (noPayFee && hasPayFee == false) {
                    let arr = ['视频问诊','图文问诊','家庭问诊','复诊'],
                        str = arr[haveFeeLogType - 1]

                    $(".popubBoxs").show()
                    $(".darkBackgroud").show()
                    $(".titleMessages").text(`您的${str}暂未结束,还不能购买其他问诊哦`)
                }
                //为该服务
                else if (hasPayFee && noPayFee == false) {
                    if (haveFeeLogType == 1 || haveFeeLogType == 2) {
                        doctor_id = $(this).attr('doctorid'); //医生id
                        // strGoUrl = 'inquiry_doctor_detail.htm?doctor_id=' + doctor_id ;
                        // goPage(strGoUrl);
                        EndTime = feeData.payEndTime
                        timer = setInterval(updateTime, 1000);
                        updateTime();
                        haveFee = 1;
                        haveFeeDoctorName = doctor_name;
                        var feeinfo = '',
                            feeinfodate = '',
                            feeinfoselect = '',
                            inquiry = '';
                        if (feeData.isOnline == 1) {
                            feeinfo +=
                                '<div class="is_online"><img src="../res/images/img_on_line.png" /></div>';
                        } else {
                            feeinfo +=
                                '<div class="is_online"><img src="../res/images/img_off_line.png" /></div>';
                        }
                        if (feeData.inquiryType == 2) {
                            inquiryType = '图文问诊'
                        } else if (feeData.inquiryType == 1) {
                            inquiryType = '视频问诊'
                        } else {}
                        feeinfo +=
                            '<div class="expertlist_map_top to_detail" num="0" id="' +
                            feeData.doctorId + '" >';
                        feeinfo += '	<div class="expertlist_map_img"> <img src="' + feeData
                            .doctorHeadImg + '" /> </div>';
                        feeinfo += '	<div class="doctor_info">';
                        feeinfo += '		<div class="doctor_name">' + feeData.trueName +
                            '<span>' + feeData.doctorJobTitle +
                            '</span>   <span>' + feeData.departmentName + '</span></div>';
                        feeinfo +=
                            '		<div class="age" style="text-align: left; ">从业年限 <span>' +
                            feeData.workDate +
                            '年</span> 年龄 <span>' + feeData.age + '岁</span></div>';
                        feeinfo += '	</div>';
                        feeinfo += '</div>';
                        feeinfodate += '您已购买 <span>' + feeData.trueName +
                            '医生</span> 的 <span>' + inquiryType +
                            '</span> 诊查费，请在有效时间内向医生发起问诊。若要更换问诊方式，请先退诊查费再重新购买。'
                        feeinfodate += '<div id="start">';
                        feeinfodate +=
                            '	剩余时间<span id="hour">00</span>:<span id="min">00</span>:<span id="sec">00</span>';
                        feeinfodate += '</div>';
                        feeinfoselect +=
                            '<a href="javascript:;" class="weui-dialog__btn default removeDialog">取消</a><a href="javascript:;" class="weui-dialog__btn primary torefee" id="' +
                            feeData.doctorId +
                            '">退诊查费</a><a href="javascript:;" class="weui-dialog__btn primary toWrite" id="' +
                            feeData.doctorId + '">发起问诊</a>'
                        $('.feeInfo').html(feeinfo);
                        $('.feeInfoDate').html(feeinfodate);
                        $('.feeInfoSelect').html(feeinfoselect);
                        $('.weui-mask').addClass('weui-mask--visible')
                        $('.weui-dialog').addClass('weui-dialog--visible')
                        $('.toWrite').on('click', function () {
                            // if (jsonInfo.data.isOnline == 0) {
                            //     msgInfo('医生不在线！');
                            //     return
                            // }
                            doctor_id = $(this).attr('id'); //医生id
                            // strGoUrl = 'inquiry_doctor_detail.htm?doctor_id=' + doctor_id ;
                            // goPage(strGoUrl);
                            if ((doctorInquiryType == 1 && haveFeeLogType == 2) || (
                                    doctorInquiryType == 2 && haveFeeLogType == 1
                                )) { //问诊类型不对
                                msgInfo('该医生当前不支持' + inquiryType);
                            } else {
                                strGoUrl =
                                    'inquiry_doctor_patient.htm?log_type=' +
                                    haveFeeLogType + '&doctor_id=' + doctor_id +
                                    '&h5_token=' + h5token + '&user_id=' +
                                    userid + '&user_type=' + usertype +
                                    '&doctor_name=' +
                                    doctor_name;
                            }
                            goPage(strGoUrl);
                        })
                        $(".torefee").on('click', function () {
                            doctor_id = parseInt($(this).attr('id')); //医生id
                            $('#androidDialog1').fadeIn(200);
                            // var params = {
                            //   "doctorId": doctor_id,
                            //   // "userId": getUserId(),
                            // }
                            // newAjaxPost("/h5/wxpay/refund", params, newRefeeOk);
                        })
                        $('.removeDialog').on('click', function () {
                            $('.weui-mask').removeClass('weui-mask--visible')
                            $('.weui-dialog').removeClass(
                                'weui-dialog--visible')
                        })
                        $('.weui-dialog__btn_primary').on('click', function () {
                            var params = {
                                "doctorId": doctor_id,
                                "isFrozen": 0
                            }
                            newAjaxPost("/h5/wxpay/refund", params, newRefeeOk);
                        })
                        $('.weui-dialog__btn_default').on('click', function () {
                            $('#androidDialog1').fadeOut(200);
                        })
                    } else if (haveFeeLogType == 3 || haveFeeLogType == 4) {
                        //有家庭医生记录
                        // logId这个参数判断用户是否填写完问卷
                        // console.log(data.logId);
                        //填完问卷，跳转聊天室
                        logId = $(this).attr("logId")
                        if (logId) {
                            //点击跳转聊天室页面
                            noticeDoctor(patientIM, doctor_imid)
                            strGoUrl = 'chat.htm?log_id=' + feeData
                                .logId +
                                '&doctor_id=' + feeData.doctorId +
                                '&doctor_imid=' +
                                feeData.doctorIm + '&log_type=' + feeData
                                .inquiryType +
                                '&inquirypatientId=' +
                                feeData.inquiryPatientId + '&patientIM=' +
                                feeData.userIm;
                            goPage(strGoUrl);
                        }
                        //没有填完问卷跳转填问卷
                        else {
                            strGoUrl = 'inquiry_doctor_patient.htm?doctor_id=' +
                                doctor_id +
                                '&doctor_name=' + doctor_name + '&log_type=' +
                                inquiryType +
                                '&h5_token=' + h5token + '&user_id=' + userid +
                                '&user_type=' + usertype + '&doctor_name=' +
                                doctor_name;
                            goPage(strGoUrl);
                        }
                    }
                } else {
                    if (inquiryType == 3) {
                        //判断是否关注
                        if (isConcern) {
                            showInquiryAsk()
                        } else {
                            $(".popubBox").show()
                            $(".darkBackgroud").show()
                            $(".btn2").text("复诊且关注医生")
                            $(".btn2").unbind("click");
                            //点击关注
                            $(".btn2").click(function () {
                                var params = {
                                    "doctorId": doctor_id,
                                    "isConcern": 1
                                }
                                newAjaxPost("/h5/myDoctor/concernDoctor", params,
                                    concernDoctorOk);
                                isConcern = true

                                function concernDoctorOk(jsonInfo) {
                                    if (jsonInfo.msg == "操作成功") {
                                        $(".popubBox").hide()
                                        $("#isConcern").hide()
                                        $(".darkBackgroud").hide()
                                        $("#cancalConcern").show()
                                        setTimeout(function () {
                                            wxDoPay()
                                        }, 1000)
                                    } else {
                                        msgInfo(data.msg);
                                    }
                                }
                            })
                        }
                    } else if (inquiryType == 1 || inquiryType == 2) {
                        var paramJson = {
                            "id": parseInt(doctor_id),
                            "im": userid
                        };
                        newAjaxPost("/h5/doctorInfo/getDoctorInfo", paramJson, (res) => {
                            //医生选择的问诊类型
                            doctorInquiryType = res.data.inquiryType
                            if (isOnline) {
                                if ((doctorInquiryType == 1 && inquiryType == 2) || (
                                        doctorInquiryType == 2 && inquiryType == 1)) {
                                    msgInfo("医生暂不支持此项问诊方式，请更换问诊方式")
                                } else {
                                    showInquiryAsk()
                                }
                            } else {
                                msgInfo("医生未上线，请等待医生上线在购买服务")
                            }
                        });
                    } else {
                        showInquiryAsk()
                    }
                }
            } else {
                msgInfo("医生未开启服务")
            }
        })

        function showInquiryAsk() {
            $(".popubBox").show()
            $(".darkBackgroud").show()
            $(".btn2").text("复诊")
            $(".btn2").unbind("click");
            $(".btn2").click(function () {
                $(".popubBox").hide()
                $("#isConcern").hide()
                $(".darkBackgroud").hide()
                $("#cancalConcern").show()
                wxDoPay()
            })
        }

        function getPatientNotice() {
            newAjaxPost('/h5/utilInitData/getAgreement', {id: 7}, function (res) {  
                $(".title").text('患者须知')
                // $('.titleMessage').html(res.data.initKey.replace(/"</, '<').replace(/>"/, '>'))
                $('.titleMessage').html(res.data.initKey)
            })
        }

        //退费成功函数
        function newRefeeOk(jsonInfo) {
            if (jsonInfo.code == 1) {
                // msgInfo('退费成功，请重新选择医生问诊');
                setTimeout(function () {
                    location.reload()
                }, 1000);
            }
        }

        function updateTime() {
            var oEndDate = new Date(EndTime.replace(/-/g, '/'))
            var oNowDate = new Date();
            var iRemain = 0;
            iRemain = parseInt((oEndDate.getTime() - oNowDate.getTime()) / 1000);
            iRemain %= 86400;
            var iHour = parseInt(iRemain / 3600); //剩余小时
            iRemain %= 3600;
            var iMin = parseInt(iRemain / 60); //剩余分钟
            iRemain %= 60;
            var iSec = iRemain; //剩余秒
            $('#hour').html(fillZero(iHour, 2));
            $('#min').html(fillZero(iMin, 2));
            $('#sec').html(fillZero(iSec, 2));
        }

        function fillZero(num, digit) {
            var str = '' + num;
            if (str.length < digit) {
                str = '0' + str;
            }
            return str;
        }
        //创建订单接口
        function payfee() {
            var params = {
                "code": 1,
                "inquiryType": inquiryType,
                "doctorId": doctor_id,
                "totalFee": parseInt(feePay)
            }
            newAjaxPost("/h5/wxpay/addConsultationFee", params, payfeeOk);
        }

        //调用微信支付
        function payfeeOk(jsonInfo) {
            console.log(jsonInfo);
            var data = [];
            if (jsonInfo.code == 1) {
                data = jsonInfo.data;
                //调起支付
                WeixinJSBridge.invoke(
                    'getBrandWCPayRequest', {
                        "appId": data.appId, //公众号名称，由商户传入       
                        "timeStamp": data.timeStamp, //时间戳，自1970年以来的秒数       
                        "nonceStr": data.nonceStr, //随机串       
                        "package": data.packageWx, //"prepay_id=" + 
                        "signType": data.signType, //微信签名方式:       
                        "paySign": data.paySign //微信签名   
                    },
                    function (res) {
                        // alert(res.err_msg)
                        if (res.err_msg == "get_brand_wcpay_request:ok") {
                            msgInfo("支付成功！");
                            //支付成功跳转填写信息页面
                            inquiryType = inquiryType;
                            doctorName = doctor_name;
                            //ios跳转用h5token
                            strGoUrl = 'inquiry_doctor_patient.htm?doctor_id=' + doctor_id +
                                '&doctor_name=' + doctor_name + '&log_type=' + inquiryType + '&h5_token=' +
                                h5token + '&user_id=' + userid + '&user_type=' + usertype;
                            goPage(strGoUrl);
                        } else
                            msgInfo('用户取消支付');
                    }
                );
            } else {
                msgInfo(jsonInfo.msg)
            }
        }

        //点击判断网页是否在浏览器打开
        function wxDoPay() {
            if (typeof WeixinJSBridge == "undefined") {
                msgInfo("此场景无法调起支付！");
                if (document.addEventListener) {
                    document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
                } else if (document.attachEvent) {
                    document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                    document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
                }
            } else {
                payfee();
            }
        }

        //轮播图
        swpier()

        // 获取用户须知
        getPatientNotice() 
    });
    // })

    //退费成功函数
    function newRefeeOk(jsonInfo) {
        if (jsonInfo.code == 1) {
            // msgInfo('退费成功，请重新选择医生问诊');
            setTimeout(function () {
                location.reload()
            }, 1000);
        }
    }

    function fillZero(num, digit) {
        var str = '' + num;
        if (str.length < digit) {
            str = '0' + str;
        }
        return str;
    }
</script>

<body ontouchstart>
    <div class="fix-top" style="z-index: 100;">
        <div class="weui-btn_primary weui-header">
            <div class="weui-header-left"><a id="btnBack" class="icon icon-109"></a></div>
            <h1 class="weui-header-title">医生主页</h1>
            <div class="weui-header-right"></div>
        </div>
    </div>

    <div class="doctorMessage"></div>
    <!-- 问诊订单查询 -->
    <div class="weui-mask" style="opacity: 1;"></div>
    <div class="weui-dialog" style="opacity: 1;">
        <div class="expertlist_map feeInfo" style="border-radius: 0px;">

        </div>
        <div class="weui-dialog__bd feeInfoDate"></div>
        <div class="weui-dialog__ft feeInfoSelect">
            <a href="javascript:;" class="weui-dialog__btn default">取消</a>
            <a href="javascript:;" class="weui-dialog__btn primary">确定</a>
        </div>
    </div>
    <div class="js_dialog" id="androidDialog1" style="display: none;">
        <div class="weui-mask"></div>
        <div class="weui-dialog weui-skin_android">
            <div class="weui-dialog__hd"><strong class="weui-dialog__title">您确认要退诊查费吗?</strong></div>
            <div class="weui-dialog__bd">
                当前问诊费会在1-3个工作日原路返回，请耐心等待
            </div>
            <div class="weui-dialog__ft">
                <a href="javascript:" class="weui-dialog__btn weui-dialog__btn_default">取消</a>
                <a href="javascript:" class="weui-dialog__btn weui-dialog__btn_primary">确定</a>
            </div>
        </div>
    </div>
    <div class="darkBackgroud"
        style="width: 100%; height: 100vh;background: rgba(0, 0, 0, 0.3);opacity: 0.3;position: fixed;z-index: 1;top: 0;">
        <p class="darkP">长按保存图片，请分享图片到微信</p>
    </div>
    <div class="popubBox">
        <div class="title">特别提醒</div>
        <div class="titleMessage ql-editor ql-snow">您好，在咨询医生前，请确保您在【三个月内】曾在实体医院就诊过，否则将无法进行线上复诊，还请您谅解。</div>
        <div class="btnList">
            <div class="btn1">首诊</div>
            <div class="btn2"> </div>
        </div>
    </div>
    <div class="popubBoxs">
        <div class="titleMessages">您的视频问诊暂未结束,还不能购买其他问诊哦</div>
        <div class="btnLists">
            <div class="btn1s">
                退款
            </div>
            <div class="btn2s">
                取消
            </div>
        </div>
    </div>
    <div class="doctor_card" id="doctor_card"></div>
    <div class="cConcern" style="z-index: 999;">
        <p style="padding:20px 0;text-align: center;color: red;" class="cancalConcern">取消关注</p>
        <p style="padding:20px 0;text-align: center;">仍然关注</p>
    </div>
    <!-- 画布 -->
    <canvas id="doctorCardCanvas" height="500" width="300" style="margin-bottom: 60px;display: none;"></canvas>
</body>

</html>